<%@page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="html" tagdir="/WEB-INF/tags" %>
<!DOCTYPE html>
<html>
<html:header title="客户选择">

    <link rel="stylesheet" href="${baseUrl}css/public.css" media="all">

    <style type="text/css">
        a{
            color: #01AAED;
            text-decoration: none;
            font-size: 12px;
        }
        a:hover {
            color: #FF5722;
        }
    </style>

    <script>
        jQuery(function () {
            fixTableOperatorButton();
            ajaxSelect("${baseUrl}custom/customType/getAll.action",'customTypeId',"客户分类");
        });

        layui.use(['form', 'table'], function () {
            let $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                util = layui.util;


            $(".close").click(function () {
                parent.layer.close(parent.layer.getFrameIndex(window.name));
            });

            renderTable();

            form.on('submit(search)', function (data) {
                let json = data.field;
                table.reload('table',{where: json,page: {curr: 1}});
                return false;
            });

            table.on('tool(table)', function (obj) {
                let data = obj.data;
                if (obj.event === 'selectOk') {
                    window.parent.getSelectCustom(data);
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                }
            });
        });

        function renderTable() {
            layui.table.render({
                id:'table'
                , elem: '#table'
                , url: "${baseUrl}custom/custom/getList.action?time="+(new Date()).valueOf()
                ,where : {
                    status :1,
                    time:(new Date()).valueOf()
                }
                , limit: 10
                , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                    layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                    //,curr: 5 //设定初始在第 5 页
                    ,groups: 5 //只显示 5 个连续页码
                    ,first: false //不显示首页
                    ,last: false //不显示尾页
                }
                , done: function(res, curr, count){
                }
                , cols: [[
                    {width:70,title:"序号",templet:function (d) {
                        return genTableIndexGreen(d.def,"默认",d);
                    }},
                    {field: 'id', width: 10, title: 'ID',hide:true},
                    {field: 'no', width: 130, title: '编号',style:"font-size:12px;"},
                    {field: 'name', width: 150, title: '名称',style:"font-size:12px;"},
                    {field: 'no', width: 130, title: '门店',style:"font-size:12px;",templet:function (d) {
                            return d.store.name;
                        }},
                    {field: 'unitTel', width: 120, title: '单位电话',style:"font-size:12px;"},
                    {field: 'contacts', width: 120, title: '联系人',style:"font-size:12px;"},
                    {field: 'phone', width: 120, title: '联系电话',style:"font-size:12px;"},
                    {width: 120, title: '分类',style:"font-size:12px;",templet:function (d) {
                            return d.customType.name;
                        }},
                    {width: 120, title: '状态',style:"font-size:12px;",templet:function (d) {
                        return d.status == '1' ? "启用":"停用";
                    }},
                    {field: 'remark', minWidth: 120, title: '备注',style:"font-size:12px;"},
                    {title: '操作', width: 70, fixed:'right', templet: '#operBar'},
                ]]
            });
        }
    </script>

</html:header>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
            <input type="hidden" name="status" value="1">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">客户分类</label>
                    <div class="layui-input-inline" >
                        <select name="customTypeId"></select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">其他信息</label>
                    <div class="layui-input-inline">
                        <input type="text" name="searchContent" placeholder="编号、名称、联系信息、备注" style="font-size: 12px;" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <a class="layui-btn" lay-submit="" lay-filter="search"><i class="layui-icon layui-icon-search"></i></a>
                </div>
            </div>
        </form>

        <hr/>

        <table class="layui-hide" id="table" lay-filter="table" lay-size="sm"></table>

        <script type="text/html" id="operBar">
            <a lay-event="selectOk" class="layui-btn layui-btn-xs table-operator">选择</a>
        </script>
    </div>
</div>

<html:loading/>
</html>